package com.imooc.sell.dataobject;

import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 季度统计实体类
 */
@Entity
@Data
@Proxy(lazy = false)
@DynamicUpdate
public class SellBySeason extends AbstractStat {
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer statBySeasonId;
    /**
     * 季度销量
     */
    private Integer sellSuccessSeason;
    /**
     * 季度销售额
     */
    private BigDecimal successSeasonSale;
    /**
     * 季度取消订单数
     */
    private Integer sellCancelSeason;
    /**
     * 季度退款订单数
     */
    private Integer sellPaybackSeason;
    /* 更新时间*/
    private Date updateTime;

    public SellBySeason() {

    }

    public SellBySeason(Integer sellSuccessSeason, BigDecimal successSeasonSale, Integer sellCancelSeason, Integer sellPaybackSeason) {
        this.sellSuccessSeason = (Integer) check(sellSuccessSeason, Integer.class);
        this.successSeasonSale = (BigDecimal) check(successSeasonSale, BigDecimal.class);
        this.sellCancelSeason = (Integer) check(sellCancelSeason, Integer.class);
        this.sellPaybackSeason = (Integer) check(sellPaybackSeason, Integer.class);
    }

    public void upToDad() {
        setSellSuccess(getSellSuccessSeason());
        setSuccessSale(getSuccessSeasonSale());
        setSellCancel(getSellCancelSeason());
        setSellPayback(getSellPaybackSeason());
        setDate(getUpdateTime());
    }
}
